package com.rem.chat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.rem.chat.pojo.dataobject.AppUpdateDO;
import com.rem.chat.service.dto.CheckVersionDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AppUpdateMapper extends BaseMapper<AppUpdateDO> {
    @Select("SELECT " +
            "version, " +
            "update_desc, " +
            "file_type, " +
            "outer_link " +
            "FROM " +
            "app_update " +
            "WHERE " +
            "version_id > #{versionId} " +
            "AND (`status` = 2 OR (`status` = 1 AND FIND_IN_SET(#{userId}, grayscale_uid))) " +
            "ORDER BY " +
            "version_id DESC " +
            "LIMIT 0, 1")
    CheckVersionDTO selectLatestVersion(@Param("versionId") Integer versionId, @Param("userId") String userId);

}
